home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / eedsrc24.zip / EEP24SRC.ZIP / EEREDRAW.C < prev    next >
C/C++ Source or Header  |  1992-07-29  |  5KB  |  122 lines

  1. /*****************************************************************************
  2. *   Program to draw EE diagrams.                         *
  3. *                                         *
  4. * This module redraw/draw all structs.                         *
  5. *                                         *
  6. * Written by:  Gershon Elber            IBM PC Ver 1.0,    Oct. 1989    *
  7. *****************************************************************************/
  8. #include <stdio.h>    /* needed for eelayer.h, it uses FILES */
  9. #include "program.h"
  10. #include "igraph.h"
  11. #include "EELayer.h"
  12. #include "eeredraw.h"
  13. #include "eestring.h"
  14.  
  15. static void RedrawStructList(DrawGenericStruct *Structs);
  16. static void RedrawOneStruct(DrawGenericStruct *Struct);
  17. static void RedrawPolylineStruct(DrawPolylineStruct *Struct);
  18. static void RedrawConnectionStruct(DrawConnectionStruct *Struct);
  19. static void RedrawTextStruct(DrawTextStruct *Struct);
  20.  
  21. /*****************************************************************************
  22. * Routine to redraw all screen. A list of all active structs is provided.    *
  23. *****************************************************************************/
  24. void RedrawAllScreen(void)
  25. {
  26.     RedrawStructList(EEDrawList);
  27. }
  28.  
  29. /*****************************************************************************
  30. * Routine to redraw list of structs.                         *
  31. * If the list is of DrawPickStruct types then the picked item are drawn.     *
  32. *****************************************************************************/
  33. static void RedrawStructList(DrawGenericStruct *Structs)
  34. {
  35.     while (Structs) {
  36.     RedrawOneStruct(Structs);
  37.     Structs = Structs -> Pnext;
  38.     }
  39. }
  40.  
  41. /*****************************************************************************
  42. * Routine to redraw list of structs.                         *
  43. *****************************************************************************/
  44. static void RedrawOneStruct(DrawGenericStruct *Struct)
  45. {
  46.     switch (Struct -> StructType)
  47.     {
  48.     case DRAW_POLYLINE_STRUCT_TYPE:
  49.         RedrawPolylineStruct((DrawPolylineStruct *) Struct);
  50.         break;
  51.     case DRAW_CONNECTION_STRUCT_TYPE:
  52.         RedrawConnectionStruct((DrawConnectionStruct *) Struct);
  53.         break;
  54.     case DRAW_TEXT_STRUCT_TYPE:
  55.         RedrawTextStruct((DrawTextStruct *) Struct);
  56.         break;
  57.     case DRAW_LIB_ITEM_STRUCT_TYPE:
  58.         DrawLibPart((DrawLibItemStruct *) Struct);
  59.         break;
  60.     }
  61. }
  62.  
  63. /*****************************************************************************
  64. * Routine to redraw polyline struct.                         *
  65. * Note wide lines are corrent for horizontal/vertical lines only.         *
  66. *****************************************************************************/
  67. static void RedrawPolylineStruct(DrawPolylineStruct *Struct)
  68. {
  69.     int i, j, x, y;
  70.  
  71.     if(!ReturnLayerMode(Struct->Layer))
  72.     return;
  73.     if (Struct -> Width == NORM_WIDTH) {
  74.     IGMoveTo(Struct -> Points[0], Struct -> Points[1]);
  75.     for (i = 1; i < Struct -> NumOfPoints; i++)
  76.         IGLineTo(Struct -> Points[i * 2], Struct -> Points[i * 2 + 1]);
  77.     }
  78.     else {
  79.     for (i = 1; i < Struct -> NumOfPoints; i++) {
  80.         x = Struct -> Points[(i - 1) * 2];
  81.         y = Struct -> Points[(i - 1) * 2 + 1];
  82.         if (x == Struct -> Points[i * 2]) {  /* Same X value (Vertical). */
  83.         for (j = -1; j <= 1; j++)
  84.             IGLineNoMap(IGMapX(x) + j,
  85.                 IGMapY(y),
  86.                 IGMapX(Struct -> Points[i * 2]) + j,
  87.                 IGMapY(Struct -> Points[i * 2 + 1]));
  88.         }
  89.         else {                /* Assume same Y Value (Horizontal). */
  90.         for (j = -1; j <= 1; j++)
  91.             IGLineNoMap(IGMapX(x),
  92.                 IGMapY(y) + j,
  93.                 IGMapX(Struct -> Points[i * 2]),
  94.                 IGMapY(Struct -> Points[i * 2 + 1]) + j);
  95.         }
  96.     }
  97.     }
  98. }
  99.  
  100. /*****************************************************************************
  101. * Routine to redraw connection struct.                         *
  102. *****************************************************************************/
  103. static void RedrawConnectionStruct(DrawConnectionStruct *Struct)
  104. {
  105.     int Width = DEFAULT_SNAP_DISTANCE / 2;
  106.     if(!ReturnLayerMode(Struct->Layer))
  107.     return;
  108.     IGBar(Struct -> PosX - Width, Struct -> PosY - Width,
  109.       Struct -> PosX + Width, Struct -> PosY + Width);
  110. }
  111.  
  112. /*****************************************************************************
  113. * Routine to redraw text struct.                         *
  114. *****************************************************************************/
  115. static void RedrawTextStruct(DrawTextStruct *Struct)
  116. {
  117.     if(!ReturnLayerMode(Struct->Layer))
  118.     return;
  119.     PutTextInfo(Struct -> Orient, Struct -> PosX, Struct -> PosY,
  120.                        Struct -> Scale,    Struct -> Text);
  121. }
  122.